using System;
using System.Collections.Generic;
using System.Text;
using virtuaPol.Util;

namespace virtuaPol.Model
{
    [Serializable]
    [System.Xml.Serialization.XmlType("person")]
    public class CPerson : virtuaPol.Util.INamedObject
    {
        // Locker object for thread safety
        private object _locker = new object();

        private string name;
        [System.Xml.Serialization.XmlAttribute("name")]
        public string Name
        {
            get { lock (_locker) { return name; } }
            set { lock (_locker) { name = value; } }
        }

        private string description;
        [System.Xml.Serialization.XmlElement("description")]
        public string Description
        {
            get { lock (_locker) { return description; } }
            set { lock (_locker) { description = value; } }
        }

        private CCountry country;
        [System.Xml.Serialization.XmlIgnore()]
        public CCountry Country
        {
            get { lock (_locker) { return country; } }
            set { lock (_locker) { country = value; } }
        }

        private ExtendedList<CProperty> properties;
        [System.Xml.Serialization.XmlArray("properties")]
        public ExtendedList<CProperty> Properties
        {
            get { lock (_locker) { return properties; } }
            set { lock (_locker) { properties = value; } }
        }

        public CPerson()
        {
            Properties = new ExtendedList<CProperty>();
        }

        public CPerson(string name)
        {
            Name = name;
            Properties = new ExtendedList<CProperty>();
        }
    }
}
